function portalExecuteAction(url){
    return $.ajax({
        type:   'POST',
        url:    url,
        async:  false
    }).responseText;
}
/*carga el formulario para editar los datos del portal*/
function ejecutarEditarPortal(){
    $('#properties_content').hide();
    $('#properties #loader').show();
    $('#properties_content').load(
        $('#properties a.edit').attr('name'),'',
        function(){
            $('#properties #loader').hide();
            $('#properties_content').show();
        }
    );
}

/*
 *  Para procesar el formulario
 *
function actualizarPortal(){
    $('#properties_content').hide();
    $('#properties #loader').show();
    $('#properties_content').load(
        $('#portal_form_edit').attr('action'),
        {title            :  $('#ems_portal_title').value+'',
         domain_url       :  $('#ems_portal_domain_url').value+'',
         published        :  $('#ems_portal_published').value+'',
         organization_id  :  $('#ems_portal_organization_id').value+'',
         css_id           :  $('#ems_portal_css_id').value+'',
         id               :  $('#ems_portal_id').value+'',
         _csrf_token      :  $('#ems_portal__csrf_token').value+''
        },
        function(){
            $('#properties #loader').hide();
            $('#properties_content').show();
        }
    );
}*/

/*
 *  Carga nuevamente los datos del portal en la zona de propiedades
 **/
function cancelarEditarPortal(){
    $('#properties_content').hide();
    $('#properties #loader').show();
    $('#properties_content').load(
        $('#properties a.edit_cancel').attr('name'),'',
        function(){
            $('#properties #loader').hide();
            $('#properties_content').show();
        }
    );
}

function actualizarPortal() {
    var options = {
        target:        '#properties_content',   // target element(s) to be updated with server response
        beforeSubmit:  showRequest  // pre-submit callback
        //success:       showResponse  // post-submit callback
    };

    $('#portal_form_edit').ajaxForm(options);
}

function showRequest(formData, jqForm, options) {
   for(i in formData){
        if(formData[i].name.indexOf("[")>0){
            formData[i].name= formData[i].name.substring(formData[i].name.indexOf("[")+1, formData[i].name.indexOf("]"));
        }
        
    }
    var queryString = $.param(formData);

    alert('About to submit: \n\n' + queryString);

    return true;
}

/*function showResponse(responseText, statusText, xhr, $form)  {
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
        '\n\nThe output div should have already been updated with the responseText.');
}*/